<%@ page import="com.lengmou.entity.Cars" %>
<%@ page import="com.lengmou.service.GoodsService" %>
<%@ page import="com.lengmou.service.impl.GoodsServiceImpl" %>
<%@ page import="com.lengmou.entity.Goods" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" errorPage="error.jsp" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="apple-mobile-web-app-title" content="魔法集市">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=1200">
    <meta name="keywords" content="GSC,寿屋,万代,眼镜工厂,千值练,海洋堂,粘土人,MAXFACTORY,ALTER,良笑,三丽鸥,Sanrio,Takaratomy,KADOKAWA,Chara-ani,AmiAmi,手办自营,周边自营,谷子自营">
    <meta name="description" content="魔法集市·自营是专注于二次元的日本代购网站以及动漫周边自营零售网站，为用户提供快捷方便的游戏动漫代购，ACG周边、声优周边、同人商品及其他日系商品一应俱全，目前支持日本亚马逊、虎穴(虎之穴)、骏河屋、Book-off、C-queen(K-books)和Melonbooks(蜜瓜)等网站的代购。与此同时，魔法集市・自营整合来自日本的第一手货源，为大家精心挑选了各种热门人气商品。所有商品均从魔法集市的日本仓库打包发出，配合全新的「喵急便」物流服务直接送达您的手中，您将能获得焕然一新的消费体验">
    <link rel="icon" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <link rel="apple-touch-icon" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <link rel="apple-touch-icon-precomposed" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <script src="js/jquery-3.1.0.js" ></script>
    <script>
        $(function () {
            var tongji=0;
            $(".cart-item-box").each(function () {
                var price= parseFloat($(this).find("#price").html());
                var num = parseInt($(this).find(".number").html());
                $(this).find("#ppp").html((price*num).toFixed(2))
                var jiage=(price*num).toFixed(2);
                tongji+=parseFloat(jiage);
            });
            $("#tongji").html(tongji);


            $('button[action="支付"]').click(function () {
                var $car = $(".cart-item-box");
                var $cars = new Array();
                 $car.each(function () {
                     if($(this).attr("data-id").length!=0){
                         $cars.push($(this).attr("data-id"));
                     }
                 })
                if($cars.length!=0){
                    $.post(
                        "buy",
                        {carsid:JSON.stringify($cars)},
                        function (date) {
                            if(date.buyState>0){
                                $("#tishi").html("购买成功").attr("class","ui-toast-box");
                                setTimeout(function () {$("#tishi").attr("class","ui-toast-box h");location.href="list.jsp";},1000);
                            }else{
                                $("#tishi").html("余额不足，请充值").attr("class","ui-toast-box");
                                setTimeout(function () {$("#tishi").attr("class","ui-toast-box h");location.href="user.jsp";},1000);
                            }
                        },"json"
                    );
                }else{
                     var $goodsid = $(".good-info-box").attr("data-id");
                     var $num = parseInt($(".number").html());
                    $.post(
                        "buy",
                        {
                            num:$num,
                            goodsid:$goodsid
                        },
                        function (date) {
                            if(date.buyState>0){
                                $("#tishi").html("购买成功").attr("class","ui-toast-box");
                                setTimeout(function () {$("#tishi").attr("class","ui-toast-box h");location.href="list.jsp";},1000);
                            }else{
                                $("#tishi").html("余额不足，请充值").attr("class","ui-toast-box");
                                setTimeout(function () {$("#tishi").attr("class","ui-toast-box h");location.href="user.jsp";},1000);
                            }
                        },"json"
                    );

                }
            });
        })
    </script>
    <title>确认订单</title>
</head>
<body>
<%@include file="header.jsp"%>
<div id="M">
    <div class="view view-confirm">
        <div class="bg-white">
            <div class="ui-layout">
                <div class="view-confirm-box" data-buy-type="1000" data-buy-step="1">
                    <div class="ui-square-box view-confirm-confirm-box view-confirm-goods-box">
                        <div class="head">
                            <h3>确认商品信息</h3></div>
                        <div class="body">
                            <div class="carts-box">
                                <!--开始循环-->
                                <c:forEach items="${cars}" var="car">
                                    <%
                                        Cars car = (Cars) pageContext.getAttribute("car");
                                        GoodsService gs = new GoodsServiceImpl();
                                        Goods goods = gs.queryGoodsByGoodsId(car.getGoodsid());
                                        pageContext.setAttribute("goods",goods);
                                    %>
                                    <div class="cart-item-box" data-sale-type="2000" data-id="${car.id}">
                                        <div class="good-info-box" data-id="${goods.id}">
                                            <a href="goodsinfo.jsp?goodsid=${goods.id}" target="_blank">
                                                <div class="cover-box">
                                                    <img src="${goods.img}"></div>
                                                <div class="info-box">
                                                    <h4>${goods.goodsname}</h4>
                                                    <div class="tags-box">
                                                        <span data-name="预售">预售</span>
                                                        <span data-name="跨境购">跨境购</span></div>
                                                </div>
                                                <p class="spec-item">规格：默认</p></a>
                                        </div>
                                        <span id="price" class="price wm1">${goods.price}</span>
                                        <div class="num-box">
                                            <div class="number">${car.num}</div></div>
                                        <div class="calc-price-box">
                                            <b>全款：
                                                <span id="ppp" class="price-item" data-price="124"></span>元</b>
                                            <span>（补款：
                    <span class="price-item" data-price="">0</span>元）</span></div>
                                    </div>
                                    <!--结束循环-->
                                </c:forEach>
                            </div>
                        </div>
                    </div>
                    <div class="ui-square-box view-confirm-calc-box">
                        <div class="body">
                            <div class="ctrl-box">
                                <div class="calc-box"></div>
                                <p class="buy-1-2000-phone">
                                    <b>补款联系手机号</b>
                                    <span>15653701040</span>&nbsp;
                                    <a href="http://www.masadora.net/user.htm#!personal" target="_blank">修改</a></p>
                                <p>
                                <b style="color: #ff5700">总计</b>
                                <span id="tongji" style="color: #ff5700">111</span>
                                    <button class="btn big" action="支付">支付</button></p>
                                <p class="address-text"></p>
                                <p class="buy-1-2000-tip">提示：本次支付的是商品定金，商品发售后进行补款，收货地址将在补款时进行填写（仅支持中国大陆）。</p></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="foot.jsp"%>
<div id="tishi" class="ui-toast-box h"></div>
</body>
</html>
